﻿myApp.controller("loginController", function ($scope, $http, $modal, $routeParams, authService, $location, $window, $rootScope) {
    $scope.loader.loading = false;
    $scope.login = function () {
        if (!$scope.loginData || !$scope.loginData.userName || !$scope.loginData.password) {
            $scope.message = "Invalid username or password!";
            return;
        }
        authService.login($scope.loginData).then(function (response) {
            $scope.user = $scope.loginData;
            
            if ($scope.authentication.userType == "Valid User") $location.path('/#');
            if ($scope.authentication.userName.indexOf('@') === -1) {
                $location.path('/ListingEntry');
            } else { $location.path('/News'); }
            

        },
         function (err) {
             $scope.message = "Invalid username or password!";
         });
    };

})